#include "Bullet.h"  
#include "BkgLayer.h"
#include "Tower.h"
#include "GlobalMgr.h"

#define ATTACKDISTANCE 10

Bullet::Bullet() : m_pParTower(NULL)
{
	schedule(schedule_selector(Bullet::checkCollision));
}
 
void Bullet::checkCollision(float dt)
{
	GlobalMgr& mgr = GlobalMgr::getInstance();
	if (!mgr.m_bGodStyle && m_pParTower )
	{
		CCPoint sheepPos = BkgLayer::m_pSheep->getPosition();
		CCPoint bulPos = ccpAdd(getPosition(), m_pParTower->getPosition());
		if (ccpDistance(sheepPos, bulPos) < 30)
		{
			BkgLayer::m_pSheep->setVisible(false);
		}
	}
}

void Bullet::setParTower(CCNode* parTower)
{
	m_pParTower = parTower;
}